using System.Collections.Generic;
using UnityEngine;

public class AbsorbBall : PoolBall
{
	[SerializeField]
	private GameObject m_AbsorbEffect;

	private List<PoolBall> m_AbsorbList = new List<PoolBall>();

	private string m_PoolKey = "Absorb";

	public List<PoolBall> AbsorbList => m_AbsorbList;

	public override void Start()
	{
		base.Start();
		SceneInitialization.Instance.InitObject(m_PoolKey, 5, m_AbsorbEffect);
	}

	public override void OnCollisionEnter(Collision col)
	{
		if (col.gameObject.name.Contains("Rail"))
		{
			AudioManager.BallhitRail(m_Rigidbody.velocity);
			if (!hitWall)
			{
				GameManager.Rules.BallHitRail(this);
				hitWall = true;
			}
		}
		if (col.gameObject.CompareTag("Ball"))
		{
			PoolBall component = col.transform.GetComponent<PoolBall>();
			if (component.ballType != 0 && component.ballType != BallType.JIANGYOU && base.BallState == State.ROLL)
			{
				Transform transform = SceneInitialization.Instance.GetObject(m_PoolKey).transform;
				transform.position = base.transform.position;
				m_AbsorbList.Add(component);
				TemporarySlot.Add(component);
			}
			else if ((m_state & (State.POTTED | State.HIDE)) == State.NONE || (col.gameObject.GetComponent<PoolBall>().BallState & (State.POTTED | State.HIDE)) == State.NONE)
			{
				AudioManager.BallhitBall(m_Rigidbody.velocity);
			}
		}
	}
}
